<?php
include '../conn.php';
$data = json_decode($HTTP_RAW_POST_DATA);
$sql = "select * from users_info
        where id = $data->id
        limit 1";
$isUser = $pdo->getOne($sql);
if($isUser) {
    $sql = "select * from users_content
            where id = $data->noticeId and user_id = $data->id
            limit 1";
    $req = $pdo->getOne($sql);
    $arr = array();
    $imgs = preg_split("/[,]+/",$req['images']);
    $imgarr = array();
    foreach($imgs as $img):
        $i = "..$img";
        $fp = fopen($i,"rb",0);
        $gambar = fread($fp,filesize($i)); 
        fclose($fp);
        $base64 = chunk_split(base64_encode($gambar)); 
        // 输出
        $encode = 'data:image/jpeg;base64,' . $base64; 
        array_push(
            $imgarr,[
                "content" => "$encode"
            ]
        );
    endforeach;
    array_push(
        $arr,[
            "id" => $req['id'],
            "title" => "$req[title]",
            "images" => $imgarr,
            "content" => "$req[content]",
            "type" => $req['type'],
            "update_time" => "$req[update_time]"
        ]
    );
}else {
    $arr = [
        "code" => 400,
        "desc" => '用户信息错误,请重试'
    ];
}
echo json_encode($arr);
exit;